//
//  DeveloperVC.m
//  AudioVideo
//
//  Created by xueshan1 on 2019/11/12.
//  Copyright © 2019 xueshan1. All rights reserved.
//

#import "DeveloperVC.h"

@interface DeveloperVC ()
@property(nonatomic,strong)NSMutableArray *dataArray;

@end

@implementation DeveloperVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = [UIColor whiteColor];
    self.dataArray = [[XSFMDBManger instance]getAllErrorLogs];
    [self.tableView reloadData];
    
}
- (IBAction)clearAcrtion:(id)sender {
    [[XSFMDBManger instance]deleteAllErrorLogs];

    self.dataArray = [[XSFMDBManger instance]getAllErrorLogs];
    [self.tableView reloadData];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    Model *m = [self.dataArray objectAtIndex:indexPath.row];
    CGSize size = [m.log getSizeWithFontSize:15 maxWidth:kWidth - 20];
    return size.height;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    Model *m = [self.dataArray objectAtIndex:indexPath.row];
    cell.textLabel.font = [UIFont systemFontOfSize:15];
    cell.textLabel.numberOfLines = 0;
    cell.textLabel.text = m.log;
    
    return cell;
}



@end
